package me.mstsc;

import me.mstsc.util.ScannerInput;

import java.io.IOException;
import java.util.List;

/**
 * @author langle__
 * @version 1.0
 */
public class Main {

    public static void main(String[] args) {
        MstscManager mstsc = MstscManager.getInstance();
        List<Account> accounts = mstsc.getAccounts();
        System.out.println("0-清理远程桌面记录");
        System.out.println();
        for (int i = 0; i < accounts.size(); i++) {
            Account account = accounts.get(i);
            String message = String.format("%d-%s %s %s", i + 1, account.getComputer(), account.getUserName(), account.getPassword());
            System.out.println(message);
        }
        System.out.println();
        //noinspection InfiniteLoopStatement
        while (true) {
            int index = ScannerInput.getInteger(":") - 1;
            try {
                if (index < 0) {
                    mstsc.clear();
                    System.out.println("远程桌面记录清理完成");
                } else if (index < accounts.size()) {
                    mstsc.connect(accounts.get(index));
                } else {
                    System.out.println("数值过大");
                }
            } catch (IOException e) {
                System.err.println(e.getMessage());
            }
        }
    }

}
